﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Temapb1_ip
{
    class Client
    {
        private int varsta;
        private string nume;
        protected Lista_Masini L;
        private int nr; 

        public Client() 
        {
            nr = 0;
            L = Lista_Masini.getInstance();
        }
        ~Client() { }

        public void setare_nume(string name)
        {
            this.nume = name;
        }

        public void setare_varsta(int age)
        {
            this.varsta = age;
        }

        public string get_nume()
        {
            return this.nume;
        }

        public int get_varsta()
        {
            return this.varsta;
        }

        public void creare_client()
        {
            string nume_client;
            int varsta_client;

            Console.WriteLine("Introduceti numele clientului ");
            nume_client = Console.ReadLine().ToUpper();
            Console.WriteLine("Introduceti varsta clientului ");
            varsta_client = Convert.ToInt32(Console.ReadLine());
            if (varsta_client >= 18)
            {
                setare_nume(nume_client);
                setare_varsta(varsta_client);
            }
            else
            { 
                Console.WriteLine("Varsta clientului trebuie sa fie mai mare de 18 ani");
                Console.WriteLine();
                creare_client();
            }

            int introd = 1;
            while (introd == 1)
            {

                Console.WriteLine("Alegeti tipul de masina pe care il doriti");
                Console.WriteLine("  1.Sedan");
                Console.WriteLine("  2.Coupe");
                Console.WriteLine("  3.Mini");

                int model = Convert.ToInt32(Console.ReadLine());//1-sedan
                if (model == 1)
                {
                    Fabrica fabrica1 = new Fabrica_Sedan();
                    Masina nou = (Sedan)fabrica1.Initializare_Masina();
                    L.set_masina(nou);
                    nr++;
                }
                else
                    if (model == 2)
                    {
                        Fabrica fabrica1 = new Fabrica_Coupe();
                        Masina nou = (Coupe)fabrica1.Initializare_Masina();
                        L.set_masina(nou);
                        nr++;
                    }
                    else
                        if (model == 3)
                        {
                            Fabrica fabrica1 = new Fabrica_Mini();
                            Masina nou = (Mini)fabrica1.Initializare_Masina();
                            L.set_masina(nou);
                            nr++;
                        }
                        else
                        {
                            Console.WriteLine("Nu exista tipul masinii");
                            creare_client();
                        }
                Console.WriteLine("Mai doriti sa introduceti vreo masina acestui client? ");
                Console.WriteLine("  0.nu ");
                Console.WriteLine("  1.da ");
                introd = Int32.Parse(Console.ReadLine());
            }
          /*  if (introd == 0)
            {
                creare_client();
            }*/
        }

        public void afisare_client()
        {
            Console.WriteLine();
            Console.WriteLine("Nume : {0} ", get_nume());
            Console.WriteLine("Varsta : {0}", get_varsta());
            L.afisare();
            Console.WriteLine("***************************");
        }
        public void stergere_masina(string nume)
        {
            L.stergere_masina(nume);
        }
       
    }
}